<?php

use yii\db\Migration;

class m171108_035625_create_class_manage_teacher extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }

    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->createTable('{{%class_manage_teacher}}',[
                'class_id' => $this->integer()->defaultValue(0)->comment('班级id'),
                'teacher_id' => $this->integer()->defaultValue(0)->comment('老师id'),
                'teacher_name' => $this->string(20)->defaultValue(null)->comment('老师'),
            ]);
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropTable('{{%class_manage_teacher}}');
        }
    }
}
